using System;
using System.Collections.Generic;

namespace MikeKappel.Com.CS
{
    public static partial class Helper
    {
     
             /// <summary>
             /// Using Generic Type
             /// Determines whether argument is null or the type's default value
             /// </summary>
             /// <typeparam name="T">Type</typeparam>
             /// <param name="arg">Argument</param>
             /// <returns>Indicates whether argument is null or default</returns>
             public static Boolean IsNullOrDefault<T>(T arg)
             {
                 return IsNullOrDefault<Object>(arg, default(T)) == default(T) as Object;
             }
             /// <summary>
             /// Using Generic Type
             /// returns Original Value if it is exceptable
             /// otherwise it returns the Default Value
             /// </summary>
             /// <typeparam name="T">Type</typeparam>
             /// <param name="arg">Original Value</param>
             /// <param name="def">Default Value</param>
             /// <returns>Original Value or Default</returns>
             public static T IsNullOrDefault<T>(T arg, T def)
             {
                 if (typeof(T) == typeof(String))
                 {
                     if (!String.IsNullOrEmpty(arg as String) && (arg as String).Trim() != "")
                         def = arg;
                 }
                 return def;
        }
    }
}